﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using Crimson;
using Crimson.Module;

public partial class FoXue_Default : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindTreeView();
            SetList("佛学经典");
        }
    }
    private void SetList(string infoTypeName)
    {
        repeater1.DataSource = InfoManager.GetInfos(infoTypeName, 0, 10, true);
        repeater1.DataBind();
    }
    private void BindTreeView()
    {
        InfoType infoType = InfoManager.DaoFactory.InfoTypeDao.Get("佛学经典");
        var node = new TreeNode();
        node.Text = infoType.Name;
        node.Value = infoType.Id.ToString();
        typeTree.Nodes.Add(node);
        CheckNodes(node, infoType);
    }

    private static void CheckNodes(TreeNode parentNode, InfoType parentNodes)
    {
        foreach (InfoType infoType in parentNodes.GetChilds())
        {
            var node = new TreeNode { Text = infoType.Name, Value = infoType.Id.ToString() };
            parentNode.ChildNodes.Add(node);
        }
    }

    protected void changeNewsType(object sender, EventArgs e)
    {
        SetList(this.typeTree.SelectedNode.Text);
    }
}